<?php

namespace App\Service\Impl;

include_once ROOT_PATH.'vendor/productai/src/Base.php';
include_once ROOT_PATH.'vendor/productai/src/API.php';

if (!defined('IN_PX'))
    exit;

use App\Service\Look;
use App\Repository;
use App\Tools\Auxi;
use ProductAI;

class LookImpl implements Look {

    //服务层组件
    private function __Service($value = 'look') {}

    private function __Value($cfg, $setting, $__ROOT__, $__CDN__, $__PACKAGE__, $__LANGUAGE_CONFIG__, $__LANGUAGE_ID__, $__ASSETS__) {}

    private $_access_key_id = '105ee5c19b8d5d5d0b3750d21f5042c7';
    private $_secret_key = '1d22822397162400bf8b352fc7d993af';
    private $_service_id = 'vcxua3bs';
    private $_count = 21;

    public function look($img) {
        $product_ai = new ProductAI\API($this->_access_key_id, $this->_secret_key, 'zh-Hans');

        $response = $product_ai->searchImage('search', $this->_service_id, $img, '', '', $this->_count);
        if ($response) {
            return $response['results'];
        } else {
            return false;
        }
    }

}
